init = function() {
	var zoom = new Zoom();
	
	var ecgGraphElement = document.getElementById("ecgGraphCanvas");
	var ecgGraphContext = ecgGraphElement.getContext("2d");
	
	$("#ecgGraphCanvas").mousedown(function(e){
			zoom.start();			zoom.setTopXY(e.pageX - ecgGraphElement.getBoundingClientRect().left, e.pageY - ecgGraphElement.getBoundingClientRect().top);
		});
	
	$("#ecgGraphCanvas").mousemove(function(e){
		if (zoom.isActive()==true) {
			clear(ecgGraphElement);
			drawGridAndCurve(ecgGraphElement, ecgGraphContext, null, 0);
			zoom.setCurrentXY(e.pageX - ecgGraphElement.getBoundingClientRect().left, e.pageY - ecgGraphElement.getBoundingClientRect().top);
			ecgGraphContext.strokeStyle = "rgba(0, 0, 0, 0)";
			ecgGraphContext.strokeRect(zoom.getTopX(), zoom.getTopY(), zoom.getCurrentWidth(), zoom.getCurrentHeight());
			ecgGraphContext.fillStyle = "rgba(0, 0, 200, 0.1)";
			ecgGraphContext.fillRect(zoom.getTopX(), zoom.getTopY(), zoom.getCurrentWidth(), zoom.getCurrentHeight());
			ecgGraphContext.stroke();
		}
	});
	
	$("#ecgGraphCanvas").mouseup(function(e){
		if (zoom.isActive() == true) {				zoom.stop();
				clear(ecgGraphElement);
				drawGridAndCurve(ecgGraphElement, ecgGraphContext, null, 0);
		}
	});
	
	jQuery.ajax({
		url: "measurementData?readingId=SUNCE0120091201113035939",
		dataType: "json",
		success: function(measurements) {
			$("#loadingImageHolder")[0].style.display='none';
			$("#graphHolder")[0].style.display='block';
			drawGridAndCurve(ecgGraphElement, ecgGraphContext, measurements, 0);
			$("#slider").slider({
				slide: function(event, ui) {
					clear(ecgGraphElement);
					drawGridAndCurve(ecgGraphElement, ecgGraphContext, null, ui.value * ((measurements.length - 640)/100));
				}
			});
		}
	});
}